<?php 

class setting_models_medias extends CI_Model{
	
	public function get_Medias(){
		$where= array('code' => 'medias');
		$query = $this->db->get_where('settings',$where);
		$setting=array();
	 	foreach ($query->result() as $row)
		      $setting[$row->setting_key]=$row->setting;
	 	if(isset($setting)) return $setting;
	 	return false;
	}
	public function create($data){
		if(!empty($data)){
			foreach ($data as $setting_key=>$setting){
				$where= array('code' => 'medias','setting_key'=>$setting_key);
				$query = $this->db->get_where('settings',$where,1);
				$post['code'] = 'medias';
				$post['setting_key'] = $setting_key;
				$post['setting'] = $setting;
				if($query->num_rows){
					$this->db->update('settings', $post,$where);
				}else{
					$this->db->insert('settings', $post);
					
				}
					
			}
		}
		return false;
	}
}